import axios from './http';
import {MASTER_URI} from '../uitls/ajaxUrl';
/**
 * Created by luqidong on 2017/12/15.
 */
/**
 * 申请彩帝
 * @param token
 * @param intro
 * @returns {*}
 */
export function applayGodR({token, intro}) {
    return axios.post(`${MASTER_URI}/ml/expert/apply`, {intro}, {
        headers: {
            token
        }
    })

}
/**
 * 检查彩帝申请状态
 * @param token
 * @returns {*}
 */
export function godApplyStatusR(token) {
    return axios.get(`${MASTER_URI}/ml/expert/applyStateValid`, {
        headers: {
            token
        }
    })
}

/**
 * 彩帝实力榜关注的
 * @param token
 * @param page
 * @returns {*}
 */
export function getMyGodListsR(token, page = 1) {
    return axios.get(`${MASTER_URI}/ml/rank/followed?page=${page}&pageSize=20`, {
        headers: {
            token
        }
    })
}

/**
 * 月人气榜
 * @param token
 * @returns {*}
 */
export function getMonyGodListsR(token) {
    if(token) {
        return axios.get(`${MASTER_URI}/ml/rank/popularity`, {
            headers: {
                token
            }
        })
    }
    else {
        return axios.get(`${MASTER_URI}/ml/rank/popularity`);
    }
}
/**
 * 实力榜
 * @param token
 * @returns {*}
 */
export function getShiLiGodListsR(token) {
    if(token) {
        return axios.get(`${MASTER_URI}/ml/rank/strength`, {
            headers: {
                token
            }
        })
    }
    else {
        return axios.get(`${MASTER_URI}/ml/rank/strength`);
    }
}

/**
 * 彩帝信息
 * @param godid
 * @param token
 * @returns {*}
 */
export function getGodInfoByIdR({godid, token}) {
    if(token) {
        return axios.get(`${MASTER_URI}/ml/expert/infoByID?expertId=${godid}`, {
            headers: {
                token
            }
        })
    }
    return axios.get(`${MASTER_URI}/ml/expert/infoByID?expertId=${godid}`);
}

/**
 * 更新彩帝个性签名
 * @param intro
 * @param token
 * @returns {*}
 */
export function updateGodIntroR({intro, token}) {
    if(token) {
        return axios.post(`${MASTER_URI}/ml/expert/updateIntro`, {intro}, {
            headers: {
                token
            }
        })
    }
}
/**
 * 彩帝推荐单
 * @param page
 * @param godid
 * @returns {*}
 */
export function godRecommendListR({page, godid}) {
    return axios.get(`${MASTER_URI}/ml/plan/byExpert?expertId=${godid}&page=${page}&pageSize=20`);
}
/**
 * 彩帝关注 + 取消
 * @param follow
 * @param token
 * @param godid
 * @returns {*}
 */
export function godFollowR({follow, token, godid}) {
    const url = follow ? `${MASTER_URI}/ml/expert/follow/cancel` : `${MASTER_URI}/ml/expert/follow`;
    return axios.post(url, {expertId: godid}, {
        headers: {
            token
        }
    });
}

/**
 * 复盘
 * @param token
 * @param content
 * @param planId
 * @returns {*}
 */
export function godReplayR({token, content, planId}) {
    return axios.post(`${MASTER_URI}/ml/plan/replay`, {content, planId}, {
        headers: {
            token
        }
    });
}